package com.example.demo.repository;

import com.example.demo.entity.Notice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface NoticeRepository extends JpaRepository<Notice,Integer> {

    @Query(value = "SELECT * FROM notice WHERE activity_id = %?1  ;",nativeQuery = true)
    Notice findByActivity_id(Integer activityId);


    @Query(value = "SELECT * FROM notice where activity_id IN (:ids) ORDER BY send_time DESC LIMIT 3 ;",nativeQuery = true)
    List<Notice> findNew(List<Integer> ids);
}
